// com.project.result.PageData.java
package com.project.result;

import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.Data;
import java.util.List;

@Data
public class PageData<T> {
    private long total;
    private long pages;
    private long current;
    private long size;
    // 字段名就是 list
    private List<T> list;

    /**
     * 从 IPage 构建 PageData（自动映射字段）
     */
    public static <T> PageData<T> of(IPage<T> page) {
        PageData<T> pd = new PageData<>();
        pd.total = page.getTotal();
        pd.pages = page.getPages();
        pd.current = page.getCurrent();
        pd.size = page.getSize();
        pd.list = page.getRecords();
        return pd;
    }
}